package cn.taoshop.interceptor;
import cn.taoshop.user.vo.User;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
public class UserLoginInterceptor extends MethodFilterInterceptor{
	
	@Override
	protected String doIntercept(ActionInvocation actionInvocation) throws Exception{
		User existUser = (User)ServletActionContext.getRequest()
				.getSession().getAttribute("existUser");
		if(existUser != null) {
			return actionInvocation.invoke();
		}  else{
			ActionSupport support = (ActionSupport) actionInvocation.getAction();
			support.addActionError("亲!您还没有登录!");
			return "userlogin";
		}
		
	}
}
